1. Field of the Invention
The present invention relates generally to an improved data processing system and in particular, to a method, system, and computer usable program code for processing program code. Still more particularly, the present invention relates to a computer implemented method, computer usable program code, and a system for parallelizing program code.
2. Description of the Related Art
Parallelization is the process by which a compiler automatically identifies and translates serial program code into equivalent parallel code for parallel processing. Parallel processing permits simultaneous processing of a portion of program code over multiple threads on one or more processors. Parallel processing can potentially enable a significant increase in execution speed of a program or application. However, in practice, not all program code can benefit from parallelization.
The challenge for automatic parallelizing compilers is to identify sections of code that can benefit from parallelization. When determining whether or not to parallelize a particular loop, the compiler assesses whether parallelization of the loop is both safe and cost-justified.
Most compilers use an all-or-none strategy to parallelize a loop. Based on a cost analysis, small loops are executed sequentially by a single thread on a single processor and large loops are selected for parallelization and executed over the maximum number of available processors.
However, using all available processors to execute parallel code can result in serious performance degradations and scalability problems. For example, when a small loop is parallelized over a large number of processors, the overhead costs of creating and setting up threads to run on processors for processing the parallel code can outweigh the benefit of parallelization.
Some research compilers have attempted to address this problem by adjusting the number of processors utilized to execute parallel code during run-time. Parallel code is initially processed by all available processors. During program execution, the number of processors used to process parallelized code is adjusted based on observed performance during code execution. However, performance degradation is a problem due to the initial use of all the available processors for parallelization. Moreover, this method also introduces additional overhead costs due to the feedback mechanism that operates during execution of the code.